
function fetchNotifications() {
    fetch('/notifications')
        .then(response => response.json())
        .then(data => {
            const panel = document.getElementById('notifications-panel');
            panel.innerHTML = ''; // 清除旧通知
            data.forEach(notif => {
                const messageElement = document.createElement('div');
                messageElement.className = 'notification-message';
                messageElement.innerText = notif.message;
                panel.appendChild(messageElement);
            });
        })
        .catch(error => console.error('Error fetching notifications:', error));
}

// 设置定时器，每2秒检查一次新通知
setInterval(fetchNotifications, 5000);




function checkFileUpload() {
    var fileInput = document.getElementById('fileInput');
    if (fileInput.value === "") {
        alert("请上传文件后再开始优化！");
        return false;  // 阻止表单提交
    }
    return true;  // 允许表单提交
}

checkFileUpload()





